<%@page contentType="text/html" pageEncoding="UTF-8" import="Modelo.*, java.util.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import = "java.util.*" %>
<%@page import = "Modelo.*" %>
<%@page import = "javax.swing.*" %>

<jsp:useBean id="proyecto" scope="request" class="Modelo.Proyecto" />
<%
//esto es para que no guarde en el cache la pagina
            response.setHeader("Cache-Control", "max-age=0");
            response.setHeader("Cache-Control", "no-cache");
            response.setHeader("Cache-Control", "no-store");
            response.setHeader("Pragma", "no-cache");
            response.setDateHeader("Expires", -1);
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Autoevaluacion</title>
        <link href="<%=request.getContextPath()%>/css/style.css" rel="stylesheet" type="text/css" media="screen" />
        <link type="text/css" href="<%=request.getContextPath()%>/jQuery/css/smoothness/jquery-ui-1.7.2.custom.css" rel="Stylesheet" />
        <script  type="text/javascript" src="<%=request.getContextPath()%>/jQuery/development-bundle/ui/ui.core.js"></script>
        <script  type="text/javascript" src="<%=request.getContextPath()%>/jQuery/development-bundle/ui/ui.draggable.js"></script>
        <script  type="text/javascript" src="<%=request.getContextPath()%>/jQuery/development-bundle/ui/ui.droppable.js"></script>

        <script type="text/javascript" src="<%=request.getContextPath()%>/jQuery/js/jquery-1.3.2.min.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/jQuery/js/jquery-ui-1.7.2.custom.min.js"></script>
        <script type="text/javascript">
            $(function() {
                $("#accordion").accordion({
                    event: "mouseover"
                });
            });
        </script>
        <style type="text/css">
            #listaOrigen6 { height: 400px; float: left; width: 45%; min-height: 18em; background: #E0E0E0; padding: 1%; overflow: auto}
            * html .lista6 { height: 12em; } /* IE6 */
            .item6 { float: left; width: 280px; padding: 0.4em; margin: 0 0.4em 0.4em 0; text-align: left;list-style-type:none; }
            .titulo6{background: white; text-align: center}
            #listaDestino6 {float: right; width: 45%; min-height: 18em; padding: 1%;  height: 400px; overflow: auto;
                            background: #E0E0E0}
            * html #trash { height: 18em; } /* IE6 */
            .titulo6{background: white; text-align: center}
        </style>

        <script  type="text/javascript">
            $(document).ready(function(){
                $(".item6").draggable({helper: 'clone' , cursor: 'move'});



                $(".lista6").droppable({
                    accept: ".item6",
                    drop: function(ev, ui) {
                        // Añado el objeto origen a la lista destino
                        $(this).append($(ui.draggable));
                    }
                });

                $("#botonResultado6").click(function () {


                    $('.lista6 li').each(function () {

                        if($(this).parent().attr('id')=='listaDestino6'){
                            crearC($(this).attr('id'));
                            //alert("1-encuesta selecionada");

                        };
                    });



                    document.form6.submit();

                });


            });


        </script>
        <script type="text/javascript">
            var num=0;
            // Funcion para crear lineas de objetos
            function crearC(idc) {
                num++;
                fi = document.getElementById('na6'); // 1
                contenedor = document.createElement('div'); // 2
                contenedor.id = 'div6'+num; // 3
                fi.appendChild(contenedor); // 4

                ele = document.createElement('input'); // 5
                ele.type = 'hidden'; // 6
                ele.name = 'caracteristica'+num;
                ele.id =idc;
                ele.value = idc;
                contenedor.appendChild(ele); // 7
            }
        </script>

    </head>

    <body>
        <%
                    HttpSession s = request.getSession();
                    if (s.getAttribute("logged") != null && s.getAttribute("logged").equals(true)) {
                        Representante rrr = (Representante) s.getAttribute("representante");
        %>


        <div style="height: 400px">

            <div align="right"  style="width: 640px; position: fixed; text-align: right"  >
                <a href="<%=request.getContextPath()%>/factor/mostrar.jsp"><img src="<%=request.getContextPath()%>/images/list.png"  style="border:0" alt="Ver"/></a>
            </div>

            <form  name="form6" action="<%=request.getContextPath() + "/factor/crearFa.jsp"%>" method="POST">
                <h3>Nuevo Factor</h3>
                <table border="0" class="form">
                    <tbody>
                        <tr>
                            <td> <p>nombre: </p></td>
                            <td> <input type="text" name="nombre" value="" /></td>
                        </tr>
                        <tr>
                            <td><p>descripcion: </p> </td>
                            <td> <input type="text" name="descripcion" value="" /></td>
                        </tr>
                    </tbody>
                </table>
                <h3>Caracteristicas</h3>
                <div>
                    <ul class="lista6" id="listaOrigen6">
                        <h4 class="titulo6"> Disponibles</h4>
                        <%


                                                List resultado = new Caracteristica().getLista();

                                                Iterator iterador = resultado.iterator();
                                                Caracteristica ca;

                                                while (iterador.hasNext()) {
                                                    ca = (Caracteristica) iterador.next();


                                                    if (ca.getFactor() == null) {
                        %>
                        <li class="item6" id="<%=ca.getId()%>"> <%=ca.getNombre()%></li>
                        <%
                                                    }

                                                }
                        %>
                    </ul>

                    <ul class="lista6" id="listaDestino6">
                        <h4 class="titulo6"> Seleccionadas</h4>
                    </ul>

                </div>
                <div id="na6"></div>

                <p><input type="button" id="botonResultado6" value="crear factor" /></p>
            </form>
            <p></p>
        </div>


        <%} else {
                        response.sendRedirect(request.getContextPath() + "/index.jsp");
                    }%>
    </body>
</html>
